<%--
  Created by IntelliJ IDEA.
  User: JYC
  Date: 2022/4/19
  Time: 14:46:31
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<div align="center" style="padding: 20px">
    <form method="post" id="getYearSell">
        <input id="bgdt" class="easyui-datebox" name="bgdt" data-options="formatter:fmt01,parser:fmt02"
               label="开始日期:" style="width:20%">&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;
        <input id="fndt" class="easyui-datebox" name="fndt" data-options="formatter:fmt01,parser:fmt02"
               label="结束日期:" style="width:20%">&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;
        <a href="javascript:void(0)" id="subbt" class="easyui-linkbutton" iconCls="icon-ok"
           onclick="getget()" style="width:90px">查询</a>
    </form>
    <div id="ecCust04" style="width: 70%;height: 400px;margin-left: 150px;margin-right: 150px"></div>
</div>
<script>
    function fmt01(date) {
        var y = date.getFullYear();
        var m = date.getMonth() + 1;
        var d = date.getDate();
        return y + '-' + m + '-' + d;
    }

    function fmt02(s) {
        if (!s) return new Date();
        var ss = (s.split('-'));
        var y = parseInt(ss[0], 10);
        var m = parseInt(ss[1], 10);
        var d = parseInt(ss[2], 10);
        if (!isNaN(y) && !isNaN(m) && !isNaN(d)) {
            return new Date(y, m - 1, d);
        } else {
            return new Date();
        }
    }

    function getget() {
        $("#getYearSell").form("submit", {
            url: 'custCount04',
            onSubmit: function () {
                return $(this).form('validate');
            },
            success: function (result) {
                // console.log(result);
                let res = JSON.parse(result);
                // console.log(res);
                if (result.errorMsg) {
                    //有错误发生
                    $.messager.show({
                        title: '提示',
                        msg: result.errorMsg
                    });
                } else {
                    var ecCust04 = echarts.init(document.getElementById('ecCust04'));
                    for (let i = 0; i < res.length; i++) {
                        // console.log('之前' + res[i][0]);
                        res[i][0] = new Date(res[i][0]);
                        // console.log(res[i][0]);
                    }
                    var option = {
                        xAxis: {
                            type: "time"
                        },
                        yAxis: {
                            type: 'value'
                        },
                        series: [
                            {
                                data: res,
                                type: 'line'
                            }
                        ]
                    };
                    ecCust04.setOption(option);
                }
            }
        });
    }
</script>
</body>
</html>
